﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication5.settings
{
    /*
    * Dynamische Routerkonfiguration mit OSPF
    */
    public class Ospf_Routerconfig
    {
        private string authentification_OSPF;
        private List<String> ips;
        private bool routingprotocol_OSPF_enable;
        private String processID_OSPF;

        /*
         * Getter und Setter
         */
        public string Authentification_OSPF
        {
            get { return authentification_OSPF; }
            set { authentification_OSPF = value; }
        }

        public List<String> Ips
        {
            get { return ips; }
            set { ips = value; }
        }

        public bool Routingprotocol_OSPF_enable
        {
            get { return routingprotocol_OSPF_enable; }
            set {  routingprotocol_OSPF_enable = value;}
        }

        public String ProcessID_OSPF
        {
            get { return processID_OSPF; }
            set { processID_OSPF = value; }
        }

        public Ospf_Routerconfig(String ospf_auth, List<String> ips, Boolean ospf_enabled, String processID_OSPF)
        {
            Authentification_OSPF = ospf_auth;
            Ips = ips;
            Routingprotocol_OSPF_enable = ospf_enabled;
            ProcessID_OSPF = processID_OSPF;
        }

        /**
         * Baut den Ausgabe-String für die OSPF-Konfiguration zusammen
         * und gibt ihn zurück
         */
        public String toString()
        {
            String ret = "";
            if (routingprotocol_OSPF_enable == true)
            {
                ret += "router ospf " + processID_OSPF + Environment.NewLine;

                foreach (String network in Ips)
                {
                    if (network != null && network != "")
                    {
                        ret += "network " + network + Environment.NewLine;
                    }
                }
                
                if (authentification_OSPF != "")
                {
                    ret += "ip ospf authentication " + authentification_OSPF + Environment.NewLine;
                }
                ret += "!" + Environment.NewLine;
            }
            return ret;
        }

    }
}
